<!DOCTYPE html>
<html lang="zh-hans">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.3.0">


  <link rel="apple-touch-icon" sizes="180x180" href="/wow/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/wow/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/wow/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/wow/images/logo.svg" color="#222">

<link rel="stylesheet" href="/wow/css/main.css">



<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.3/css/all.min.css">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/animate.css@3.1.1/animate.min.css">

<script class="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"single-flower.gitee.io","root":"/wow/","images":"/wow/images","scheme":"Muse","version":"8.3.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":false,"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"بحث...","empty":"We didn't find any results for the search: ${query}","hits_time":"${hits} results found in ${time} ms","hits":"${hits} results found"}};
  </script>
<meta name="description" content="直播直播：流式传输协议，传输非常短的一小截视频观看直播浏览器：video标签客户端工具：vlc播放器 协议rtmp协议 推流（使用OBS）将现场的视频信号传到网络的过程，对网络要求比较高OBS下载地址：https:&#x2F;&#x2F;obsproject.com&#x2F;zh-cn 拉流（使用浏览器或Vlc）服务器已有直播内容，根据协议类型（如RTMP、RTP、RTSP、HTTP等），与服务器建立连接并接收数据，进行拉取">
<meta property="og:type" content="article">
<meta property="og:title" content="视频直播">
<meta property="og:url" content="https://single-flower.gitee.io/wow/2021/02/18/zy/%E8%A7%86%E9%A2%91%E7%9B%B4%E6%92%AD/index.html">
<meta property="og:site_name" content="朵朵最可爱">
<meta property="og:description" content="直播直播：流式传输协议，传输非常短的一小截视频观看直播浏览器：video标签客户端工具：vlc播放器 协议rtmp协议 推流（使用OBS）将现场的视频信号传到网络的过程，对网络要求比较高OBS下载地址：https:&#x2F;&#x2F;obsproject.com&#x2F;zh-cn 拉流（使用浏览器或Vlc）服务器已有直播内容，根据协议类型（如RTMP、RTP、RTSP、HTTP等），与服务器建立连接并接收数据，进行拉取">
<meta property="og:locale">
<meta property="article:published_time" content="2021-02-18T10:40:59.201Z">
<meta property="article:modified_time" content="2021-04-13T07:05:16.253Z">
<meta property="article:author" content="X y">
<meta property="article:tag" content="-GIT">
<meta name="twitter:card" content="summary">


<link rel="canonical" href="https://single-flower.gitee.io/wow/2021/02/18/zy/%E8%A7%86%E9%A2%91%E7%9B%B4%E6%92%AD/">


<script class="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-hans'
  };
</script>
<title>视频直播 | 朵朵最可爱</title>
  




  <noscript>
  <style>
  body { margin-top: 2rem; }

  .use-motion .menu-item,
  .use-motion .sidebar,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header {
    visibility: visible;
  }

  .use-motion .header,
  .use-motion .site-brand-container .toggle,
  .use-motion .footer { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle,
  .use-motion .custom-logo-image {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line {
    transform: scaleX(1);
  }

  .search-pop-overlay, .sidebar-nav { display: none; }
  .sidebar-panel { display: block; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="تشغيل شريط التصفح" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/wow/" class="brand" rel="start">
      <i class="logo-line"></i>
      <h1 class="site-title">朵朵最可爱</h1>
      <i class="logo-line"></i>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu">
        <li class="menu-item menu-item-home"><a href="/wow/" rel="section"><i class="fa fa-home fa-fw"></i>Home</a></li>
        <li class="menu-item menu-item-about"><a href="/wow/about/" rel="section"><i class="fa fa-user fa-fw"></i>معلومات</a></li>
        <li class="menu-item menu-item-tags"><a href="/wow/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>الوسوم</a></li>
        <li class="menu-item menu-item-categories"><a href="/wow/categories/" rel="section"><i class="fa fa-th fa-fw"></i>التصنيفات</a></li>
        <li class="menu-item menu-item-archives"><a href="/wow/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>الأرشيفات</a></li>
  </ul>
</nav>




</div>
        
  
  <div class="toggle sidebar-toggle" role="button">
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
  </div>

  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          المحتويات
        </li>
        <li class="sidebar-nav-overview">
          عام
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%9B%B4%E6%92%AD"><span class="nav-number">1.</span> <span class="nav-text">直播</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E7%9B%B4%E6%92%AD%EF%BC%9A%E6%B5%81%E5%BC%8F%E4%BC%A0%E8%BE%93%E5%8D%8F%E8%AE%AE%EF%BC%8C%E4%BC%A0%E8%BE%93%E9%9D%9E%E5%B8%B8%E7%9F%AD%E7%9A%84%E4%B8%80%E5%B0%8F%E6%88%AA%E8%A7%86%E9%A2%91"><span class="nav-number">1.1.</span> <span class="nav-text">直播：流式传输协议，传输非常短的一小截视频</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E8%A7%82%E7%9C%8B%E7%9B%B4%E6%92%AD"><span class="nav-number">1.2.</span> <span class="nav-text">观看直播</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%8D%8F%E8%AE%AE"><span class="nav-number">1.3.</span> <span class="nav-text">协议</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%8E%A8%E6%B5%81%EF%BC%88%E4%BD%BF%E7%94%A8OBS%EF%BC%89"><span class="nav-number">1.4.</span> <span class="nav-text">推流（使用OBS）</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%8B%89%E6%B5%81%EF%BC%88%E4%BD%BF%E7%94%A8%E6%B5%8F%E8%A7%88%E5%99%A8%E6%88%96Vlc%EF%BC%89"><span class="nav-number">1.5.</span> <span class="nav-text">拉流（使用浏览器或Vlc）</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%B8%B8%E8%A7%81%E7%9A%84%E7%9B%B4%E6%92%AD%E5%8D%8F%E8%AE%AE"><span class="nav-number">2.</span> <span class="nav-text">常见的直播协议</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#RTMP%E7%9B%B4%E6%92%AD%E5%8D%8F%E8%AE%AE"><span class="nav-number">2.1.</span> <span class="nav-text">RTMP直播协议</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E4%BC%98%E7%82%B9"><span class="nav-number">2.2.</span> <span class="nav-text">优点</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E7%BC%BA%E7%82%B9"><span class="nav-number">2.3.</span> <span class="nav-text">缺点</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#HTTP-FLV%E7%9B%B4%E6%92%AD%E5%8D%8F%E8%AE%AE"><span class="nav-number">2.4.</span> <span class="nav-text">HTTP-FLV直播协议</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E4%BC%98%E7%82%B9-1"><span class="nav-number">2.5.</span> <span class="nav-text">优点</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E7%BC%BA%E7%82%B9-1"><span class="nav-number">2.6.</span> <span class="nav-text">缺点</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#HLS%E7%9B%B4%E6%92%AD%E5%8D%8F%E8%AE%AE"><span class="nav-number">2.7.</span> <span class="nav-text">HLS直播协议</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E4%BC%98%E7%82%B9-2"><span class="nav-number">2.8.</span> <span class="nav-text">优点</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E7%BC%BA%E7%82%B9-2"><span class="nav-number">2.9.</span> <span class="nav-text">缺点</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%BA%91%E4%B8%BB%E6%9C%BA%E6%90%AD%E5%BB%BA%E7%9B%B4%E6%92%AD"><span class="nav-number">3.</span> <span class="nav-text">云主机搭建直播</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%88%9B%E5%BB%BA%E8%BD%AF%E4%BB%B6%E7%9A%84%E5%AD%98%E5%82%A8%E4%BD%8D%E7%BD%AE"><span class="nav-number">3.1.</span> <span class="nav-text">创建软件的存储位置</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E4%B8%8B%E8%BD%BDnginx"><span class="nav-number">3.2.</span> <span class="nav-text">下载nginx</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E4%B8%8B%E8%BD%BD%E7%9B%B4%E6%92%AD%E6%A8%A1%E5%9D%97"><span class="nav-number">3.3.</span> <span class="nav-text">下载直播模块</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E8%A7%A3%E5%8E%8B%E4%B8%8B%E8%BD%BD%E5%A5%BD%E7%9A%84nginx"><span class="nav-number">3.4.</span> <span class="nav-text">解压下载好的nginx</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E8%A7%A3%E5%8E%8B%E4%B8%8B%E8%BD%BD%E5%A5%BD%E7%9A%84rtmp%E7%9B%B4%E6%92%AD%E6%A8%A1%E5%9D%97"><span class="nav-number">3.5.</span> <span class="nav-text">解压下载好的rtmp直播模块</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E8%BF%9B%E5%85%A5%E8%A7%A3%E5%8E%8B%E5%A5%BD%E7%9A%84nginx%E4%B8%8B%E7%9B%AE%E5%BD%95%EF%BC%8C%E5%B9%B6%E8%BF%9B%E8%A1%8C%E5%AE%89%E8%A3%85%E5%89%8D%E7%9A%84%E9%85%8D%E7%BD%AE"><span class="nav-number">3.6.</span> <span class="nav-text">进入解压好的nginx下目录，并进行安装前的配置</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E7%BC%96%E8%AF%91%E5%8F%8A%E5%AE%89%E8%A3%85"><span class="nav-number">3.7.</span> <span class="nav-text">编译及安装</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E7%9B%B8%E5%85%B3"><span class="nav-number">4.</span> <span class="nav-text">配置文件相关</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E4%BF%AE%E6%94%B9%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6"><span class="nav-number">4.1.</span> <span class="nav-text">修改配置文件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6http%E6%8B%89%E6%B5%81%E9%83%A8%E5%88%86"><span class="nav-number">4.2.</span> <span class="nav-text">配置文件http拉流部分</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%9C%8D%E5%8A%A1%E7%9B%B8%E5%85%B3"><span class="nav-number">5.</span> <span class="nav-text">服务相关</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%85%B3%E9%97%AD%E6%97%A7%E6%9C%89%E6%9C%8D%E5%8A%A1"><span class="nav-number">5.1.</span> <span class="nav-text">关闭旧有服务</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%BC%80%E5%90%AF%E6%96%B0%E6%9C%8D%E5%8A%A1"><span class="nav-number">5.2.</span> <span class="nav-text">开启新服务</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%8E%A8%E6%8B%89%E6%B5%81%E5%9C%B0%E5%9D%80"><span class="nav-number">6.</span> <span class="nav-text">推拉流地址</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%8E%A8%E6%B5%81%E5%9C%B0%E5%9D%80"><span class="nav-number">6.1.</span> <span class="nav-text">推流地址</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%8B%89%E6%B5%81%E5%9C%B0%E5%9D%80"><span class="nav-number">6.2.</span> <span class="nav-text">拉流地址</span></a></li></ol></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author site-overview-item animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">X y</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap site-overview-item animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/wow/archives/">
        
          <span class="site-state-item-count">23</span>
          <span class="site-state-item-name">المقالات</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
        <span class="site-state-item-count">1</span>
        <span class="site-state-item-name">التصنيفات</span>
      </div>
      <div class="site-state-item site-state-tags">
        <span class="site-state-item-count">1</span>
        <span class="site-state-item-name">الوسوم</span>
      </div>
  </nav>
</div>



        </div>
      </div>
    </div>
  </aside>
  <div class="sidebar-dimmer"></div>


    </header>

    
  <div class="back-to-top" role="button" aria-label="Back to top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-hans">
    <link itemprop="mainEntityOfPage" href="https://single-flower.gitee.io/wow/2021/02/18/zy/%E8%A7%86%E9%A2%91%E7%9B%B4%E6%92%AD/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/wow/images/avatar.gif">
      <meta itemprop="name" content="X y">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="朵朵最可爱">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          视频直播
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">نُشر في</span>

      <time title="أُنشأ: 2021-02-18 18:40:59" itemprop="dateCreated datePublished" datetime="2021-02-18T18:40:59+08:00">2021-02-18</time>
    </span>
      <span class="post-meta-item">
        <span class="post-meta-item-icon">
          <i class="far fa-calendar-check"></i>
        </span>
        <span class="post-meta-item-text">عُدل في</span>
        <time title="عُدل: 2021-04-13 15:05:16" itemprop="dateModified" datetime="2021-04-13T15:05:16+08:00">2021-04-13</time>
      </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">في</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/wow/categories/GIT/" itemprop="url" rel="index"><span itemprop="name">-GIT</span></a>
        </span>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
        <h2 id="直播"><a href="#直播" class="headerlink" title="直播"></a>直播</h2><h3 id="直播：流式传输协议，传输非常短的一小截视频"><a href="#直播：流式传输协议，传输非常短的一小截视频" class="headerlink" title="直播：流式传输协议，传输非常短的一小截视频"></a>直播：流式传输协议，传输非常短的一小截视频</h3><h3 id="观看直播"><a href="#观看直播" class="headerlink" title="观看直播"></a>观看直播</h3><p>浏览器：video标签<br>客户端工具：vlc播放器</p>
<h3 id="协议"><a href="#协议" class="headerlink" title="协议"></a>协议</h3><p>rtmp协议</p>
<h3 id="推流（使用OBS）"><a href="#推流（使用OBS）" class="headerlink" title="推流（使用OBS）"></a>推流（使用OBS）</h3><p>将现场的视频信号传到网络的过程，对网络要求比较高<br>OBS下载地址：<a target="_blank" rel="noopener" href="https://obsproject.com/zh-cn">https://obsproject.com/zh-cn</a></p>
<h3 id="拉流（使用浏览器或Vlc）"><a href="#拉流（使用浏览器或Vlc）" class="headerlink" title="拉流（使用浏览器或Vlc）"></a>拉流（使用浏览器或Vlc）</h3><p>服务器已有直播内容，根据协议类型（如RTMP、RTP、RTSP、HTTP等），与服务器建立连接并接收数据，进行拉取的过程<br>Vlc下载地址：<a target="_blank" rel="noopener" href="https://www.videolan.org/vlc/">https://www.videolan.org/vlc/</a></p>
<h2 id="常见的直播协议"><a href="#常见的直播协议" class="headerlink" title="常见的直播协议"></a>常见的直播协议</h2><h3 id="RTMP直播协议"><a href="#RTMP直播协议" class="headerlink" title="RTMP直播协议"></a>RTMP直播协议</h3><p>RTMP 是专为流媒体开发的协议，对底层的优化比其它协议更加优秀</p>
<h3 id="优点"><a href="#优点" class="headerlink" title="优点"></a>优点</h3><p>它对 Adobe Flash 支持好<br>基本上所有的编码器（摄像头之类）都支持 RTMP 输出<br>另外RTMP适合长时间播放，即 10 天多连续播放没有出现问题，稳定<br>最后 RTMP 的延迟相对较低，一般延时在 1-3s 之间，一般的视频会议，互动式直播，完全是够用的</p>
<h3 id="缺点"><a href="#缺点" class="headerlink" title="缺点"></a>缺点</h3><p>它是基于 TCP 传输，非公共端口，可能会被防火墙阻拦<br>RTMP 为 Adobe 私有协议，很多设备无法播放，兼容性不高<br>Html基础支持不好，无法直接使用HTML标签完成拉流</p>
<h3 id="HTTP-FLV直播协议"><a href="#HTTP-FLV直播协议" class="headerlink" title="HTTP-FLV直播协议"></a>HTTP-FLV直播协议</h3><p>FLV: 简单轻量、加载速度极快、播放快</p>
<h3 id="优点-1"><a href="#优点-1" class="headerlink" title="优点"></a>优点</h3><p>可以直接通过http协议进行传输，http属于公共协议，公共端口：80<br>支持加密，使用https<br>兼容移动端设备，比如：安卓、ios</p>
<h3 id="缺点-1"><a href="#缺点-1" class="headerlink" title="缺点"></a>缺点</h3><p>会缓存直播数据，保存直播传输过来的一段段flv文件，隐私保密不好<br>不能在大并发情况下使用</p>
<h3 id="HLS直播协议"><a href="#HLS直播协议" class="headerlink" title="HLS直播协议"></a>HLS直播协议</h3><p>苹果公司实现的基于 HTTP 的流媒体传输协议</p>
<h3 id="优点-2"><a href="#优点-2" class="headerlink" title="优点"></a>优点</h3><p>数据通过 HTTP 协议传输，所以采用 HLS 时不用考虑防火墙或者代理的问题。<br>使用短时长的分片文件来播放，客户端可以平滑的切换码率，以适应不同带宽条件下的播放。<br>HLS 是苹果推出的流媒体协议，在 iOS 平台上可以获得天然的支持，采用系统提供的 AVPlayer 就能直接播放，不用自己开发播放器</p>
<h3 id="缺点-2"><a href="#缺点-2" class="headerlink" title="缺点"></a>缺点</h3><p>通常 HLS 直播延时会达到 20-30s，而高延时对于需要实时互动体验的直播来说是不可接受的。<br>HLS 基于短连接 HTTP，HTTP 是基于 TCP 的，这就意味着 HLS 需要不断地与服务器建立连接，TCP 每次建立连接时的三次握手、慢启动过程、断开连接时的四次挥手都会产生消耗</p>
<h2 id="云主机搭建直播"><a href="#云主机搭建直播" class="headerlink" title="云主机搭建直播"></a>云主机搭建直播</h2><h3 id="创建软件的存储位置"><a href="#创建软件的存储位置" class="headerlink" title="创建软件的存储位置"></a>创建软件的存储位置</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">mkdir /usr/local/nginx-flv</span><br><span class="line"><span class="comment">// 创建了一个安装目录</span></span><br><span class="line">mkdir /home/flv-tools</span><br><span class="line"><span class="comment">// 存储所需软件</span></span><br></pre></td></tr></table></figure>
<h3 id="下载nginx"><a href="#下载nginx" class="headerlink" title="下载nginx"></a>下载nginx</h3><p>高性能多路复用服务器，让你支持同时响应多个客户连接<br>多线程、多进程开发模式<br>wget <a target="_blank" rel="noopener" href="https://nginx.org/download/nginx-1.18.0.tar.gz">https://nginx.org/download/nginx-1.18.0.tar.gz</a></p>
<h3 id="下载直播模块"><a href="#下载直播模块" class="headerlink" title="下载直播模块"></a>下载直播模块</h3><p>git clone <a target="_blank" rel="noopener" href="https://github.com/winshining/nginx-http-flv-module">https://github.com/winshining/nginx-http-flv-module</a></p>
<h3 id="解压下载好的nginx"><a href="#解压下载好的nginx" class="headerlink" title="解压下载好的nginx"></a>解压下载好的nginx</h3><p>tar -zxvf nginx-1.18.0.tar.gz nginx-1.18.0/</p>
<h3 id="解压下载好的rtmp直播模块"><a href="#解压下载好的rtmp直播模块" class="headerlink" title="解压下载好的rtmp直播模块"></a>解压下载好的rtmp直播模块</h3><p>unzip nginx-http-flv-module.zip</p>
<h3 id="进入解压好的nginx下目录，并进行安装前的配置"><a href="#进入解压好的nginx下目录，并进行安装前的配置" class="headerlink" title="进入解压好的nginx下目录，并进行安装前的配置"></a>进入解压好的nginx下目录，并进行安装前的配置</h3><p>cd nginx-1.18.0<br>./configure –prefix=/usr/local/nginx-flv –add-module=/home/flv-tools/nginx-http-flv-module-master<br>–prefix: 配置安装路径<br>–add-module: 添加安装插件</p>
<h3 id="编译及安装"><a href="#编译及安装" class="headerlink" title="编译及安装"></a>编译及安装</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">make </span><br><span class="line">make install </span><br><span class="line">------------</span><br><span class="line">make &amp;&amp; make install </span><br></pre></td></tr></table></figure>
<h2 id="配置文件相关"><a href="#配置文件相关" class="headerlink" title="配置文件相关"></a>配置文件相关</h2><h3 id="修改配置文件"><a href="#修改配置文件" class="headerlink" title="修改配置文件"></a>修改配置文件</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><span class="line">worker_processes  <span class="number">1</span>;</span><br><span class="line"></span><br><span class="line">rtmp_auto_push on;</span><br><span class="line">rtmp_auto_push_reconnect 1s;</span><br><span class="line">rtmp_socket_dir /tmp;</span><br><span class="line"></span><br><span class="line">rtmp&#123;</span><br><span class="line">	out_queue <span class="number">4096</span>;</span><br><span class="line">	out_cork <span class="number">8</span>;</span><br><span class="line">	max_streams <span class="number">128</span>;</span><br><span class="line">	timeout 15s;</span><br><span class="line">	drop_idle_publisher 15s;</span><br><span class="line">	log_interval 5s;</span><br><span class="line">	log_size 1m;</span><br><span class="line">	server &#123;</span><br><span class="line">		listen 1935; # 推流端口</span><br><span class="line">		server_name zege;</span><br><span class="line">		</span><br><span class="line">		application live &#123;	# 配置推流地址</span><br><span class="line">			live on; # 打开推流</span><br><span class="line">			# gop_cache on;</span><br><span class="line">			# rtmp://123.123.123.123:1935/live/test</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">events &#123;</span><br><span class="line">    worker_connections  <span class="number">1024</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h3 id="配置文件http拉流部分"><a href="#配置文件http拉流部分" class="headerlink" title="配置文件http拉流部分"></a>配置文件http拉流部分</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">http &#123;</span><br><span class="line">	include       mime.types;</span><br><span class="line">	default_type  application/octet-stream;</span><br><span class="line">	sendfile        on;</span><br><span class="line">	keepalive_timeout  <span class="number">65</span>;</span><br><span class="line">	server &#123;</span><br><span class="line">		listen       8080; # 拉流通过8080去拉流</span><br><span class="line">		# http://123.123.123.123:8080/live/?port=1935&amp;stream=test</span><br><span class="line">		server_name  localhost;</span><br><span class="line">		location /live &#123;</span><br><span class="line">			flv_live on;</span><br><span class="line">			chunked_transfer_encoding  on;</span><br><span class="line">			add_header <span class="string">&#x27;Access-Control-Allow-Origin&#x27;</span> <span class="string">&#x27;*&#x27;</span>;</span><br><span class="line">			add_header <span class="string">&#x27;Access-Control-Allow-Credentials&#x27;</span> <span class="string">&#x27;true&#x27;</span>;</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h2 id="服务相关"><a href="#服务相关" class="headerlink" title="服务相关"></a>服务相关</h2><h3 id="关闭旧有服务"><a href="#关闭旧有服务" class="headerlink" title="关闭旧有服务"></a>关闭旧有服务</h3><p>/usr/local/nginx-rtmp/sbin/nginx -s stop<br>/usr/local/nginx-rtmp/sbin/nginx -s reload<br>重启</p>
<h3 id="开启新服务"><a href="#开启新服务" class="headerlink" title="开启新服务"></a>开启新服务</h3><p>/usr/local/nginx-flv/sbin/nginx -c /usr/local/nginx-flv/conf/nginx.conf<br>记得打开阿里云的防火墙哦</p>
<h2 id="推拉流地址"><a href="#推拉流地址" class="headerlink" title="推拉流地址"></a>推拉流地址</h2><h3 id="推流地址"><a href="#推流地址" class="headerlink" title="推流地址"></a>推流地址</h3><p>rtmp://云主机的ip:端口/live/密钥</p>
<h3 id="拉流地址"><a href="#拉流地址" class="headerlink" title="拉流地址"></a>拉流地址</h3><p>http://云主机的ip:8080/live?port=端口&amp;app=live&amp;stream=密钥</p>

    </div>

    
    
    

    <footer class="post-footer">
          <div class="post-tags">
              <a href="/wow/tags/GIT/" rel="tag"># -GIT</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/wow/2021/02/18/zy/model%E5%AE%9E%E7%8E%B0%E6%97%A0%E9%99%90%E6%9E%81%E5%88%86%E7%B1%BB/" rel="prev" title="model实现无限极分类">
                  <i class="fa fa-chevron-left"></i> model实现无限极分类
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/wow/2021/02/18/zy/docker%E6%93%8D%E4%BD%9C%E5%AE%B9%E5%99%A8%EF%BC%8C%E9%95%9C%E5%83%8F/" rel="next" title="docker操作容器，镜像">
                  docker操作容器，镜像 <i class="fa fa-chevron-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>







<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      const activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      const commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>
</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">


<div class="copyright">
  &copy; 
  <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">X y</span>
</div>
  <div class="powered-by">تطبيق الموقع <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.js.org/muse/" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a>
  </div>

    </div>
  </footer>

  
  <script src="https://cdn.jsdelivr.net/npm/animejs@3.2.1/lib/anime.min.js"></script>
<script src="/wow/js/utils.js"></script><script src="/wow/js/motion.js"></script><script src="/wow/js/schemes/muse.js"></script><script src="/wow/js/next-boot.js"></script>

  






  





</body>
</html>
